/*******************************************************************************
 * Copyright (c) 2011 Olexandr V. Shaposhnikov.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Olexandr V. Shaposhnikov - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.funkyroach.use.ui.toolkit;

import org.eclipse.dltk.core.IDLTKLanguageToolkit;
import org.eclipse.dltk.core.IScriptFolder;
import org.eclipse.dltk.ui.AbstractDLTKUILanguageToolkit;
import org.eclipse.dltk.ui.ScriptElementLabels;
import org.eclipse.dltk.ui.text.ScriptSourceViewerConfiguration;
import org.eclipse.dltk.ui.text.ScriptTextTools;
import org.eclipse.jface.preference.IPreferenceStore;

import com.funkyroach.use.core.language.USLanguageToolkit;
import com.funkyroach.use.plugin.USPlugin;
import com.funkyroach.use.ui.text.IUSPartitionTokens;
import com.funkyroach.use.ui.text.USSourceViewerConfiguration;

public class USUILanguageToolkit extends AbstractDLTKUILanguageToolkit {

	private static ScriptElementLabels sScriptElementLabels = new ScriptElementLabels() {
		protected void getScriptFolderLabel(IScriptFolder folder,
				StringBuffer buf) {
			String name = folder.getElementName();
			name = name.replace(IScriptFolder.PACKAGE_DELIMITER, '.');
			buf.append(name);
		}
	};

	@Override
	public IDLTKLanguageToolkit getCoreToolkit() {
		return USLanguageToolkit.getDefault();
	}

	@Override
	public IPreferenceStore getPreferenceStore() {
		return USPlugin.instance().getPreferenceStore();
	}

	public ScriptSourceViewerConfiguration createSourceViewerConfiguration() {
		return new USSourceViewerConfiguration(USPlugin.instance()
				.getTextTools().getColorManager(), getPreferenceStore(), null,
				IUSPartitionTokens.US_PARTITIONING);
	}

	@Override
	public ScriptTextTools getTextTools() {
		return USPlugin.instance().getTextTools();
	}

	@Override
	public ScriptElementLabels getScriptElementLabels() {
		return sScriptElementLabels;
	}

	public String getPartitioningId() {
		return IUSPartitionTokens.US_PARTITIONING;
	}

	@Override
	public String getInterpreterPreferencePage() {
		return null; //USInstalledUDKPreferencePage.ID;
	}

}
